﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="InsertSessionDates.aspx.cs" Inherits="TheatreStaff_InsertSessionDates" %>
<%@ Register TagPrefix="custom" Namespace="myControls" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.Configuration" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script type="text/javascript">

    function displayCalendar() {
        var datePicker = document.getElementById('datePicker');
        datePicker.style.display = 'block';
    }
</script>
<script runat ="server" >
    protected void Clear(object sender, EventArgs e)
    {
        Label15.Text = string.Empty;
        Label16.Text = string.Empty;
    }
    protected void ClearAll(object sender, EventArgs e)
    {
        Label15.Text = "";
        Label16.Text = "";
    }
    protected void Cancel(object sender, EventArgs e)
    {
       
        txtDateI.Text = string.Empty;
        ddlMovieTitleI.SelectedIndex = -1;
        ddlscheduleI.SelectedIndex = -1;
        //ddlSessionI.SelectedItem.Text = "Select";
        ddlTypeI.SelectedIndex = -1;
        ddlCinema.SelectedIndex = -1;
        Label15.Text = "";
        Label16.Text = "";
        //grdSession.DataBind();
    }

    protected void Insert(object sender, EventArgs e)
    {
        Label15.Text = "";
        Label16.Text = "";
        string connectionString;
        connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection con = new SqlConnection(connectionString);
        SqlConnection con1 = new SqlConnection(connectionString);
        SqlCommand cmd1 = new SqlCommand("INSERT datesession(date,sessionid,movieid,sessiontype,scheduleid) values (@date,@sessionid,@movieid,@sessiontype,@scheduleid)", con1);
        SqlCommand cmd = new SqlCommand("SELECT datesession.date,datesession.sessionid from datesession,Movie,TheatreStaff WHERE TheatreStaff.TheatreId=Movie.TheatreId AND datesession.movieid=Movie.MovieId AND Movie.TheatreId=@TheatreId AND datesession.date=@date AND datesession.sessionid=@sessionid", con);
        string ParamString = lblId.Text;
        Int32 RowCount;
        Boolean HasMovies;

        cmd.Parameters.AddWithValue("@TheatreId", ParamString);
        cmd.Parameters.AddWithValue("@date", DateTime.Parse(txtDateI.Text) );
        cmd.Parameters.AddWithValue("@sessionid", ddlSessionI.SelectedValue);
        //cmd.Parameters.AddWithValue("@movieid", ddlMovieTitleI.SelectedValue );

        using (con)
        {
            con.Open();
            SqlDataReader Reader = cmd.ExecuteReader();

            if (Reader.HasRows)
            {
                
                Label15.Text = "The session date " + txtDateI.Text + " already exist in the database!";
                
                //lblCheck.Text = string.Empty;
                //ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "Focus", "<script language='JavaScript' 'showInsert();'/>");

                HasMovies = true;

            }
            else
            {
                HasMovies = false;

            }
        }
        using (con1)
        {
            con1.Open();
            if (HasMovies == false)
            {
                cmd1.Parameters.AddWithValue("@date",DateTime.Parse(txtDateI.Text));
                cmd1.Parameters.AddWithValue("@sessionid", ddlSessionI.SelectedValue );
                cmd1.Parameters.AddWithValue("@movieid", ddlMovieTitleI.SelectedValue );
                cmd1.Parameters.AddWithValue("@sessiontype", ddlTypeI.SelectedValue );
                cmd1.Parameters.AddWithValue("@scheduleid", ddlscheduleI.SelectedValue );
                RowCount = cmd1.ExecuteNonQuery();
                txtDateI .Text  = string.Empty;
                ddlMovieTitleI.SelectedIndex = -1;
            
                //ddlSessionI.SelectedItem.Text = "Select";
                ddlTypeI.SelectedIndex = -1;
                ddlCinema.SelectedIndex = -1;
                //if (RowCount > 0)
                //{
                //ddlscheduleI.
                if( ddlscheduleI.SelectedValue != "-1" ) 
                Label16.Text  = "The session " + txtDateI.Text  + " has been added sucessfully!";
                ddlscheduleI.SelectedIndex = -1;

                //}
            }

        }
        //grdSession.DataBind();
    }
    void Page_Load()
    {
        //if (!Page.IsPostBack)
            //grdSession.SelectedIndex = 0;
        //Label15.Text = string.Empty;
        //Label16.Text = string.Empty;
    }
    protected void OnItemInserted_Click(object sender, DetailsViewInsertedEventArgs e)
    {
        //grdSession.DataBind();
        Label15.Text = "";
        Label16.Text = "";
            
    }
    protected void OnItemUpdated_Click(object sender, DetailsViewUpdatedEventArgs e)
    {
        //grdSession.DataBind();
        Label15.Text = "";
        Label16.Text = "";
    }
</script>

<%--This below code from the website:http://ramanisandeep.wordpress.com/2008/11/07/hide-an-aspnet-label-control-after-a-few-seconds/--%>
<script type="text/javascript">
    self.setInterval("changeValue1()", 5000);

    function changeValue1() {
        document.getElementById("Label15").innerText = "";

    }
    self.setInterval("changeValue()", 5000);
    function changeValue() {
        document.getElementById("Label16").innerText = "";

    }
</script>
 <style type="text/css">
        #datePicker
        {
            display:none;
            position:absolute;
            border:solid 2px black;
            background-color:white;
           
        }
    
    </style>
<style type="text/css">
.center2
{
    padding-left:250px;
}
#divDisplay
{
    border:solid 1px White;
    width:400px;
    padding:15px;
    margin:0px auto;
    text-align:center;
    border:1px solid #333;
}
.C
{
  color:#FFFFCC;
    font-size:larger;
    font-weight :bolder ;
}
.I
{
    color:red;
    font-size:larger;
    font-weight :bolder ;
}
.center1
{
    padding-left:320px;
}
#divInsert
{
    display:none;
    border:solid 1px black;
    width:500px;
    position:absolute;
    top:200px;
    left:100px;
    padding:10px;
    background-color:Silver;
    color:Black ;
}
html
{
  background-image:url('image/back.jpg'); 

    padding:10px;
    color:White;    
  
}
.content1
{
    margin:auto;
    width:950px;
}
.column
{
    float:left;
    width:348px;
}
.selectedRow
{
    background-color:Silver;
}

.content
{
    width:950px;
    margin:auto;
        height: 197px;
}

.link
{
  margin-left:350px; 
     font-weight:bold;
  font-size:large;  
    font-size:x-large;
}
.link2
{
  margin-left:50px; 
     font-weight:bold;
  font-size:large;  
    font-size:x-large;
}
a
{
 color: white;
 text-decoration:underline;
 font-weight:bold;

}
a:hover
{
 color: red; 
  text-decoration:none;
  font-weight:bold;

}
.join
{
   background-color:#0099FF;
  clip:auto;
  font-weight:bold;
  font-size:large;
}
.table2
{
 border-style:solid;
   border-color:Black;
   background-color:White;
   color:Black;  
   width:900px; 
}
.row
{
   background-color:Gray;
   color:White;
}
.ticket
{
   background-color:#CC0000;
color:White;

}

.ticket:hover
{
 color: black; 
  text-decoration:none;


}
    .style1
    {
        width: 509px;
    }
    
.footer
{

     font-weight:bold;
  font-size:large;  

}
.ticket1
{
    padding-left:200px;
}
.view2
{
 padding-left:250px;  
}
.text
{
 font-weight:bold;
}
.button
{
 margin-left:250px;
}
.view3
{
    padding-left:120px;
}
.footer
{

   margin-top:250px;
}
.center
{
    padding-left:360px;
}
.legend
{
    
    color:White;    
}  
.cinema
{
    padding-left:590px;
}
           .menu
{
 padding-left:140px;  

}
</style>
    <title>Session Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div class="content">
  <asp:Image ID="Image1" Width="1000" Height="130" ImageUrl="~/image/tdk-jun5-bannerbatmanexclusivo2.jpg" runat="server" /><br />
<asp:HyperLink ID="HyperLink14"  CssClass="link" NavigateUrl="~/Default.aspx" runat="server">Home</asp:HyperLink>
<asp:HyperLink ID="HyperLink1"  CssClass="link2" NavigateUrl="~/Session.aspx" runat="server">Session</asp:HyperLink> <asp:HyperLink ID="HyperLink2" CssClass="link2" NavigateUrl="~/Movie.aspx" runat="server">Movies</asp:HyperLink>
<asp:HyperLink ID="HyperLink3" CssClass="link2"  NavigateUrl="~/Price.aspx" runat="server">Prices</asp:HyperLink>

<br /> <br />
  <%-- <asp:Label ID="Label5" runat="server"  Text="Theatre" CssClass="cinema" Font-Bold="True" Font-Underline="True"></asp:Label>
        <asp:Label ID="Label51" runat="server"  ForeColor="Yellow"></asp:Label>
      
&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp 
          <asp:Label ID="Label11" runat="server" Text="UserName" Font-Bold="True"></asp:Label>    <asp:LoginName ID="LoginName1" runat="server" /> 
    &nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp<asp:LoginStatus ID="LoginStatus1" runat="server" ForeColor="#99CCFF" />--%>
<table class="center1" >
        <tr>
            <td>
               <asp:Label ID="Label5" CssClass="menu"  runat="server"  Text="Theatre" Font-Bold="True" Font-Underline="True"></asp:Label>  
            </td>
            <td>
                 <asp:Label ID="Label51" runat="server"  ForeColor="Yellow"></asp:Label>
                 &nbsp;&nbsp
            </td>
       <%-- </tr>
 </table> --%>
    <%--<td>&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp</td>--%>
<%--&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp --%>
  <%--<table align="center" >
        <tr>--%>
            <td>
                <asp:Label ID="Label12" runat="server" Text="UserName" Font-Bold="True"></asp:Label>
                &nbsp;&nbsp;
            </td>
            <td>
                <asp:LoginName ID="LoginName1" runat="server" /> 
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </td>
            <td>
                 <asp:LoginStatus ID="LoginStatus1" runat="server" ForeColor="#99CCFF" />
                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </td>
        </tr>
    </table>
        <hr />
  <asp:Label ID="Label10" runat="server" Text="Maintain:" Font-Bold="True" Font-Size="Larger" Font-Underline="True"></asp:Label>
<asp:HyperLink ID="HyperLink4" runat="server" 
            NavigateUrl="~/TheatreStaff/Cinema.aspx" ForeColor="#FFCC99">[Cinemas]</asp:HyperLink>&nbsp;&nbsp;
    <asp:HyperLink ID="HyperLink5" runat="server"  ForeColor="#FFFF99" NavigateUrl="~/TheatreStaff/Movies.aspx">[Movies]</asp:HyperLink> &nbsp;
    <asp:HyperLink ID="HyperLink144" runat="server" NavigateUrl="~/TheatreStaff/Schedule.aspx" ForeColor="#FF9900">[Schedules]</asp:HyperLink>&nbsp;   
 <asp:HyperLink ID="HyperLink117" runat="server" NavigateUrl="~/TheatreStaff/Session.aspx" ForeColor="#FF6699">[Session Times]</asp:HyperLink>&nbsp;  
  <asp:HyperLink ID="HyperLink116" runat="server" NavigateUrl="~/TheatreStaff/SessionDates.aspx" ForeColor="#66FF66">[Session Date]</asp:HyperLink>&nbsp;    
 <asp:HyperLink ID="HyperLink115" runat="server" NavigateUrl="~/TheatreStaff/SpecialTickets.aspx" ForeColor="Aqua">[Specail Price]</asp:HyperLink>&nbsp;&nbsp;
 <asp:HyperLink ID="HyperLink107" runat="server" NavigateUrl="~/TheatreStaff/specialday.aspx" ForeColor="#CCFF33">[Special Ticket Pricing Days]</asp:HyperLink>&nbsp;  
    <asp:HyperLink ID="HyperLink6" runat="server" NavigateUrl="~/TheatreStaff/SalesReports.aspx" ForeColor="#CCFFFF">[Sales Report]</asp:HyperLink>&nbsp; 
            <asp:HyperLink ID="HyperLink11" runat="server" NavigateUrl="~/TheatreStaff/AddNewUser.aspx" ForeColor="#66FF99">[Add New User]</asp:HyperLink>&nbsp; 
  <hr />
            <h3><asp:Label ID="Label2" Text ="Insert Session Dates" runat="server" CssClass="center" ForeColor="#66FF66" /></h3>   
             <asp:BulletedList ID="BulletedList1" CssClass ="center2" ForeColor="#66FF66" runat="server">
            <%--<asp:ListItem> When you insert the release date, please insert folowing the format: mm/dd/yyyy</asp:ListItem>--%>
            <asp:ListItem Text ="Click 'Cancel' to return to the Session Dates Maintenance section" />
            </asp:BulletedList>
    
    <br />   
     <%--<div class ="content1">--%>
        <asp:ScriptManager
        id="sm1"
        Runat="server" />
         <asp:UpdatePanel
                    id="up1"
                    Runat="server">
                     <ContentTemplate>
             <asp:Label ID="Label15" CssClass="I" runat="server"   ></asp:Label> 
                    <%--<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator"></asp:CustomValidator>--%>
                    <%--<asp:RequiredFieldValidator ID="reqError" runat="server" ControlToValidate="lblError" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>--%>
                    
             <asp:Label ID="Label16" CssClass="C" runat="server"  Text=""></asp:Label>
        <asp:Label ID="lblId" runat="server" Visible="false" Text=""></asp:Label>
         <table  >
            <tr>
                <td> <h3><asp:Label ID="Label1" Text ="Maintain Movie Sesssions Dates" Visible="false"  runat="server" /></h3></td>
            </tr>
         </table>
          <%--  <div class="column">--%>
        
            <%--<asp:GridView ID="grdSession"
            AllowPaging="true" DataSourceID ="srcgrdSession"
            AutoGenerateSelectButton ="true" OnSelectedIndexChanged ="Clear"
            DataKeyNames ="datesessionid,cinema" AutoGenerateColumns ="false" runat="server" 
                 Height="360px" Width="16px">
                <Columns >
                    <custom:DeleteButtonField CommandName="Delete" ConfirmText ="Are you sure that you want to delete this record?" />
                  
                   <%-- <asp:BoundField DataField="sessionid" Visible="false" HeaderText ="Session Id" />--%>
                   <%-- <asp:BoundField DataField ="cinema" HeaderText ="Cinema Id" />
                    <asp:BoundField DataField ="MovieTitle" HeaderText ="Movie Title" />
                    <asp:BoundField DataField ="date" HeaderText ="Date" DataFormatString ="{0:d}" />--%>
                    <%--<asp:BoundField DataField ="time" HeaderText ="Session Time" DataFormatString ="{0:t}" />--%>
               <%-- </Columns>
            </asp:GridView>
            <a href="JavaScript:showInsert();">Insert Session Dates </a>
           </div>--%>
         <%--<div class="column">
               <asp:DetailsView ID="dtlSpecial" 
               AutoGenerateEditButton ="true" AutoGenerateInsertButton ="true" OnItemInserted ="OnItemInserted_Click" OnItemUpdated ="OnItemUpdated_Click"   
               AutoGenerateRows ="false" runat="server"  DataKeyNames ="datesessionid" DataSourceID ="srcSessionSelect">
                <Fields >
                     <asp:TemplateField HeaderText ="Session Time" HeaderStyle-Font-Bold="true">
                        <ItemTemplate>
                            <%# Eval("sessionid")%> 
                        </ItemTemplate>
                        <EditItemTemplate >
                            <asp:DropDownList 
                                    ID="ddlSession" 
                                     DataSourceID ="srcSessionid" 
                                     DataTextField ="time"
                                     DataValueField ="sessionid"
                                     SelectedValue='<%# Bind("sessionid") %>'
                                     runat="server" AppendDataBoundItems ="true" >
                                     <asp:ListItem Text ="Select" Value ="-1" />
                                    </asp:DropDownList> 
                                <asp:RequiredFieldValidator
                                    id="reqSession"
                                    ControlToValidate="ddlSession"
                                    InitialValue ="-1" 
                                    Text="(Required)"
                                    Runat="server" />
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText ="Movie Title" HeaderStyle-Font-Bold="true">
                        <ItemTemplate>
                            <%# Eval("MovieTitle")%> 
                        </ItemTemplate>
                        <EditItemTemplate >
                            <asp:DropDownList 
                                    ID="ddlMovieTitle" 
                                     DataSourceID ="srcMovie" 
                                     DataTextField ="MovieTitle"
                                     DataValueField ="MovieId"
                                     SelectedValue='<%# Bind("movieid") %>'
                                     runat="server" AppendDataBoundItems ="true" >
                                     <asp:ListItem Text ="Select" Value ="-1" />
                                    </asp:DropDownList> 
                                <asp:RequiredFieldValidator
                                    id="reqMovie"
                                    ControlToValidate="ddlMovieTitle"
                                    InitialValue ="-1" 
                                    Text="(Required)"
                                    Runat="server" />
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText ="Session Date" HeaderStyle-Font-Bold="true">
                        <ItemTemplate>
                            <%# Eval("date","{0:d}")%> 
                        </ItemTemplate>
                        <EditItemTemplate>
                                  <asp:TextBox
                                    id="txtSessionDate"
                                    Text='<%# Bind("date","{0:d}") %>'
                                    Runat="server"/>
                                  <asp:RequiredFieldValidator
                                    id="reqDate"
                                    ControlToValidate="txtSessionDate"
                                    Text="(Required)"
                                    Runat="server" />
                                <asp:CompareValidator ID="cmpDate" ControlToValidate ="txtSessionDate" runat="server" 
                                ErrorMessage="(Please enter a valid date in the mm/dd/yyyy format)" 
                                Operator="DataTypeCheck" Type="Date">
                                </asp:CompareValidator>      
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText ="Session Type" HeaderStyle-Font-Bold="true">
                        <ItemTemplate>
                            <%# Eval("sessiontype")%> 
                        </ItemTemplate>
                        <EditItemTemplate >
                            <asp:DropDownList 
                                    ID="ddlType" 
                                     DataSourceID ="srcType" 
                                     DataTextField ="sessiontype"
                                     DataValueField ="sessiontype"  
                                     SelectedValue='<%# Bind("sessiontype") %>'
                                     runat="server" AppendDataBoundItems ="true" >
                                     <asp:ListItem Text ="Select" Value ="-1" />
                                    </asp:DropDownList> 
                                <asp:RequiredFieldValidator
                                    id="reqsessiontype"
                                    ControlToValidate="ddlType"
                                    InitialValue ="-1" 
                                    Text="(Required)"
                                    Runat="server" />
                        </EditItemTemplate>
                    </asp:TemplateField>
                     <asp:TemplateField HeaderText ="Schedule Start Date" HeaderStyle-Font-Bold="true">
                        <ItemTemplate>
                            <%# Eval("ScheduleStartDate", "{0:d}")%> 
                        </ItemTemplate>
                         <EditItemTemplate >
                            <asp:DropDownList 
                            ID="ddlschedule" 
                             DataSourceID ="srcSchedule" 
                             DataTextField ="ScheduleStartDate"
                             DataValueField ="ScheduleId"  
                             SelectedValue='<%# Bind("scheduleid") %>'
                             runat="server" AppendDataBoundItems ="true" >
                             <asp:ListItem Text ="Select" Value ="-1" />
                            </asp:DropDownList> 
                            <asp:RequiredFieldValidator
                                id="reqSchedule"
                                ControlToValidate="ddlSchedule"
                                InitialValue ="-1" 
                                Text="(Required)"
                                Runat="server" />
                        </EditItemTemplate>
                    </asp:TemplateField>
                  </Fields>
               </asp:DetailsView>
           </div>      
    </div>--%>
    <%--<div id="divInsert">--%>
     
        <fieldset >
            <legend class ="legend" >Insert Session Dates</legend>
            <table  align="center">
                
                <tr>
                <td>
                    <asp:Label ID="Label3" runat="server" Text="Date"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtDateI" OnTextChanged="ClearAll" runat="server"></asp:TextBox>
                </td>
                <td>
                     <asp:RequiredFieldValidator
                    id="reqDateI"
                    ControlToValidate="txtDateI"
                    Text="(Required)"
                    Runat="server" />
                </td>
                <td>
                        <asp:RegularExpressionValidator 
                     ID="RegularExpressionValidator2I" 
                     ControlToValidate="txtDateI" 
                     runat="server" 
                     ErrorMessage="(Please enter a valid date in the dd/MM/yyyy format)"
                      ValidationExpression="(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d">
                      </asp:RegularExpressionValidator>  
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label4" runat="server" Text="Movie Title"></asp:Label>
                </td>
                <td>
                     <asp:DropDownList 
                    ID="ddlMovieTitleI" 
                     DataSourceID ="srcMovie" 
                     DataTextField ="MovieTitle"
                     DataValueField ="MovieId"
                     runat="server" AppendDataBoundItems ="true" >
                     <asp:ListItem Text ="Select" Value ="-1" />
                    </asp:DropDownList> 
                </td>
                <td>
                <asp:RequiredFieldValidator
                    id="reqMovieI"
                    ControlToValidate="ddlMovieTitleI"
                    InitialValue ="-1" 
                    Text="(Required)"
                    Runat="server" />
                </td>
                </tr> 
             
                <tr>
                
                <td>
                <asp:Label ID="Label9" runat="server" Text="Cinema"></asp:Label>
                </td>
                <td>
                 
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:DropDownList 
                    ID="ddlCinema" 
                     DataSourceID ="srcCinema" 
                     DataTextField ="CinemaId"
                     DataValueField ="CinemaId" 
                      AutoPostBack="true" 
                     runat="server" AppendDataBoundItems ="true" >
                     <asp:ListItem Text ="Select" Value ="-1" />
                    </asp:DropDownList>
                    </ContentTemplate>
                      </asp:UpdatePanel>
                 </td>
                 <td> 
                    <asp:RequiredFieldValidator
                    id="RequiredFieldValidator1"
                    ControlToValidate="ddlCinema"
                    InitialValue ="-1" 
                    Text="(Required)"
                    Runat="server" />
                </td>
                </tr>
                <tr>
                <td>
                <asp:Label ID="Label6" runat="server" Text="Session Time"></asp:Label>
                </td>
                <td>
                    
                    <asp:DropDownList 
                    ID="ddlSessionI" 
                     DataSourceID ="srcSessionid" 
                     DataTextField ="time"
                     DataValueField ="sessionid"
                     runat="server"  >
                     <asp:ListItem Text ="Select" Value ="-1" />
                    </asp:DropDownList>
                   
                 </td>
                 <td> 
                    <asp:RequiredFieldValidator
                    id="reqSessionI"
                    ControlToValidate="ddlSessionI"
                    InitialValue ="-1" 
                    Text="(Required)"
                    Runat="server" />
                </td>
                </tr>
               
                <tr>
                <td>
                    <asp:Label ID="Label7" runat="server" Text="Session Type"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList 
                    ID="ddlTypeI" 
                     DataSourceID ="srcType" 
                     DataTextField ="sessiontype"
                     DataValueField ="sessiontype"
                     runat="server" AppendDataBoundItems ="true" >
                     <asp:ListItem Text ="Select" Value ="-1" />
                    </asp:DropDownList> 
                </td>
                <td>
                    <asp:RequiredFieldValidator
                    id="reqsessiontypeI"
                    ControlToValidate="ddlTypeI"
                    InitialValue ="-1" 
                    Text="(Required)"
                    Runat="server" />
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label8" runat="server" Text="Schedule Start Date"></asp:Label>
                </td>
                <td>
                     <asp:DropDownList 
                    ID="ddlscheduleI" 
                     DataSourceID ="srcSchedule" 
                     DataTextField ="ScheduleStartDate"
                     DataValueField ="ScheduleId" DataTextFormatString ="{0:dd/MM/yyyy}"
                     runat="server" AppendDataBoundItems ="true" >
                     <asp:ListItem Text ="Select" Value ="-1" />
                    </asp:DropDownList> 
                </td>
                <td>
                     <asp:RequiredFieldValidator
                    id="reqScheduleI"
                    ControlToValidate="ddlScheduleI"
                    InitialValue ="-1" 
                    Text="(Required)"
                    Runat="server" />
                </td>
                </tr>
                </table>
               
                <table>
                <tr>
                <td>
                    <%--<asp:Button ID="Button1"   runat="server" Text="Button" />--%>
                    <asp:LinkButton ID="btnInsert"  CssClass="view2" OnClick ="Insert" runat="server">Insert Movie</asp:LinkButton>
                </td>
               
                <td>
                    <asp:LinkButton ID="btnCancel" PostBackUrl="~/TheatreStaff/SessionDates.aspx" OnClick ="Cancel" CommandName="Cancel" CausesValidation ="false"  runat="server">Cancel</asp:LinkButton>
                </td>
                </tr>
            </table>
         </fieldset>
                  </ContentTemplate> 
                    </asp:UpdatePanel>
            
   <%--  </div>--%>
     
     
     
      <%-- <asp:SqlDataSource ID="srcgrdSession" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT datesession.datesessionid,datesession.date,datesession.sessionid,
            datesession.movieid,Movie.MovieTitle,datesession.sessiontype,datesession.scheduleid,Schedule.ScheduleStartDate,session2.cinema 
            FROM Movie,datesession,session2,Cinema,Schedule,TheatreStaff WHERE 
            datesession.sessionid=session2.sessionid AND Movie.MovieId=datesession.movieid AND
            Schedule.ScheduleId=datesession.scheduleid AND Cinema.CinemaId=session2.cinema
            AND TheatreStaff.TheatreId=Cinema.TheatreId AND TheatreStaff.TheatreStaffUserName = @username"
            DeleteCommand ="DELETE datesession WHERE datesessionid=@datesessionid " >
            
                 <SelectParameters>
                  <asp:Parameter Name ="username" Type ="string"/> 
                 </SelectParameters>--%>
                 <%--<DeleteParameters >
                    <%--<asp:ControlParameter Name="date" ControlID ="grdSession"/>--%>
                      <%-- <asp:ControlParameter Name="datesessionid" ControlID ="grdSession" />
                 </DeleteParameters>--%>
            <%--</asp:SqlDataSource>--%>
         
          <%--  <asp:SqlDataSource ID="srcSessionSelect" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="SELECT datesession.datesessionid,Schedule.ScheduleStartDate,datesession.sessionid,datesession.date,Movie.MovieTitle,
            datesession.movieid,datesession.sessiontype,datesession.scheduleid FROM datesession,Movie,Schedule
            WHERE  datesession.datesessionid=@datesessionid AND  Movie.MovieId=datesession.movieid "
      
             UpdateCommand ="UPDATE datesession SET date=@date,movieid=@movieid,sessiontype=@sessiontype,
        scheduleid=@scheduleid,sessionid=@sessionid
            WHERE datesessionid=@datesessionid"
            InsertCommand="INSERT INTO datesession(date,movieid,sessiontype,scheduleid,sessionid)
            VALUES (@date,@movieid,@sessiontype,@scheduleid,@sessionid)"
             runat="server">--%>
                <%--<SelectParameters>
                  <asp:ControlParameter Name ="datesessionid" ControlID ="grdSession"  PropertyName='SelectedDataKey("datesessionid")'  />
<%--                  <asp:ControlParameter Name="date" ControlID ="grdSession"   PropertyName='SelectedDataKey("date")'  />--%>
               <%-- </SelectParameters>--%>
                <%--<UpdateParameters > 
                  <asp:ControlParameter Name ="datesessionid" ControlID ="grdSession"/>--%>
                
                 <%-- <asp:ControlParameter Name="date" ControlID ="grdSession"   PropertyName='SelectedDataKey("date")'  />--%>
                <%--</UpdateParameters>--%>
          <%--  </asp:SqlDataSource>--%>
             
            <asp:SqlDataSource ID="srcType" runat="server" 
                  ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                  SelectCommand="SELECT DISTINCT sessiontype FROM datesession">
            </asp:SqlDataSource>
            
            <asp:SqlDataSource ID="srcSchedule" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT ScheduleId, ScheduleStartDate FROM Schedule WHERE TheatreId=@TheatreId">
                <SelectParameters >
                    <asp:ControlParameter Name ="TheatreId" ControlID ="lblId"/>
                </SelectParameters>
            </asp:SqlDataSource>
            
            <asp:SqlDataSource ID="srcMovie" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT Movie.MovieTitle,Movie.MovieId ,Movie.showing FROM Movie WHERE Movie.TheatreId=@TheatreId AND Movie.showing='true'">
                <SelectParameters >
                    <asp:ControlParameter Name ="TheatreId" ControlID ="lblId"/>
                </SelectParameters>
            </asp:SqlDataSource>
            
            <asp:SqlDataSource ID="srcSessionid" runat="server"  ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand ="SELECT DISTINCT session2.time,session2.sessionid FROM session2, Cinema WHERE Cinema.CinemaId = 
            session2.cinema AND Cinema.TheatreId=@TheatreId AND session2.cinema=@cinema Order By session2.time">
                <SelectParameters >
                    <asp:ControlParameter Name ="TheatreId" ControlID ="lblId"/>
                    <asp:ControlParameter  Name ="cinema" ControlID ="ddlCinema" PropertyName="SelectedValue" />
                </SelectParameters>
            </asp:SqlDataSource>
             <%--<asp:SqlDataSource ID="srcCinema" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT DISTINCT session2.cinema FROM session2,Cinema,TheatreStaff WHERE TheatreStaff.TheatreId=Cinema.TheatreId AND Cinema.TheatreId=@TheatreId">
                <SelectParameters >
                    <asp:ControlParameter Name ="TheatreId" ControlID ="lblId"/>
                </SelectParameters>
            </asp:SqlDataSource>--%>
             <asp:SqlDataSource ID="srcCinema" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT DISTINCT CinemaId FROM Cinema WHERE TheatreId=@TheatreId">
                <SelectParameters >
                    <asp:ControlParameter Name ="TheatreId" ControlID ="lblId"/>
                </SelectParameters>
            </asp:SqlDataSource>
      
    <br /> <br />
 <table width="100" cellpadding="15" ><tr><td>Copyright@2012 MovieTix</td><td><asp:HyperLink ID="HyperLink8"  CssClass="footer" NavigateUrl="~/Default.aspx" runat="server">Homepage</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink9"  CssClass="footer" NavigateUrl="~/Session.aspx" runat="server">Session</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink10"  CssClass="footer" NavigateUrl="~/Movie.aspx" runat="server">Movies</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink12"  CssClass="footer" NavigateUrl="~/register.aspx" runat="server">Register</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink13"  CssClass="footer" NavigateUrl="~/Login.aspx" runat="server">Log In</asp:HyperLink></td></tr></table>
       </div>  
    </form>
</body>
</html>